package com.alibaba.nacos.naming.core.v2.client.impl;

import com.alibaba.nacos.naming.core.v2.client.AbstractClient;
import com.alibaba.nacos.naming.core.v2.pojo.InstancePublishInfo;
import com.alibaba.nacos.naming.core.v2.pojo.Service;
import lombok.Getter;
import lombok.Setter;

import java.util.Collection;
import java.util.List;

@Getter
@Setter
public class ConnectionBasedClient
        extends AbstractClient {

    private final String connectionId;
    private final boolean isNative;
    private volatile long lastRenewTime;

    public ConnectionBasedClient(String connectionId,
                                 boolean isNative,
                                 Long revision) {
        super(revision);
        this.connectionId = connectionId;
        this.isNative = isNative;
        this.lastRenewTime = System.currentTimeMillis();
    }

    @Override
    public String getClientId() {
        return connectionId;
    }

    @Override
    public boolean isEphemeral() {
        return true;
    }

    @Override
    public boolean isExpire(long currentTime) {
        return !isNative && currentTime - getLastRenewTime() > 30000;
    }
}
